package com.pdg.mcplugin.questfor.config;

import java.util.Set;

import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;

import com.pdg.mcplugin.common.baseclasses.PluginClientBase;
import com.pdg.mcplugin.questfor.QuestFor;

public class QuestsManager extends PluginClientBase<QuestFor> {

	private static final String QUESTS_SECTION = "quests";
	private static final String THRESHHOLD = "threshhold";
	public QuestsManager(QuestFor thePlugin) {
		super(thePlugin);
	}

	public Set<String> getQuestNames() {
		FileConfiguration theConfig = getPlugin().getConfig();
		ConfigurationSection theQuestsSection = theConfig.getConfigurationSection(QUESTS_SECTION);
		return theQuestsSection.getValues(false).keySet();
	}
	
	public boolean hasQuestConfig(String theName){
		FileConfiguration theConfig = getPlugin().getConfig();
		ConfigurationSection theQuestsSection = theConfig.getConfigurationSection(QUESTS_SECTION);
		return theQuestsSection.isSet(theName);
	}
	
	public QuestConfig getQuestConfig(String theName){
		if(!hasQuestConfig(theName)) return null;
		FileConfiguration theConfig = getPlugin().getConfig();
		ConfigurationSection theQuestsSection = theConfig.getConfigurationSection(QUESTS_SECTION);
		ConfigurationSection theQuest = theQuestsSection.getConfigurationSection(theName);
		return new QuestConfig(theQuest);
	}
	
	public double getThreshhold(){
		FileConfiguration theConfig = getPlugin().getConfig();
		return theConfig.getDouble(THRESHHOLD);
	}
}
